import pandas as pd

def linear_func(a, b, x):
    x_coords, y_coords = zip(a,b)
    A = np.vstack([x_coords, np.ones(len(x_coords))]).T
    m, c = lstsq(A, y_coords, rcond=None)[0]
    return m*x + c

data_file = "output_hp.dat"

#Data
df_data = pd.read_csv(data_file, sep="\s+")

fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8,5))

# Chi-Squared minimal
chi2min = min(df_data[df_data["obsratio"]<1.0]["chi2"])

print("Chi-Squared minimal : ", chi2min)
print("length", len(df_data.index))

for i in range(len(df_data.index)-1):
    #Pass limit + HB
    df_pass_HB = df_data[df_data["obsratio"]<1.0]
    #Pass HB+ST+HS
    df_pass_HS = df_pass_HB[df_pass_HB["chi2"]-chi2min<5.99]

    mh = df_pass_HS["mh"].values
    mh = df_pass_HS["mh"].values
    mh = df_pass_HS["mh"].values

